import React, { useEffect } from "react";
import styles from "./index.module.less";
import WithHead from "../message/WithHead";
import { connect } from "react-redux";
import { getAllLeaveMessagesAction } from "@redux/actions02";

const AllMessages = (props) => {
    const { getAllLeaveMessagesAction, list } = props;

    useEffect(() => {
        getAllLeaveMessagesAction && getAllLeaveMessagesAction();
    }, [getAllLeaveMessagesAction]);

    return (
        <div className={styles.all_messages}>
            {list &&
                list.map((item, index) => {
                    return <WithHead key={index} item={item} />;
                })}
        </div>
    );
};

export default connect(
    (state) => ({
        list: state.allLeaveMessagesReducer,
    }),
    { getAllLeaveMessagesAction }
)(AllMessages);
